package org.odefu.flash.display
{
	import flash.display.MovieClip;
	import flash.geom.Rectangle;

	public class FrameBoundsCache
	{
		private const frameBounds:Vector.<Rectangle> = new Vector.<Rectangle>();
		
		public function FrameBoundsCache(mc:MovieClip)
		{
			for (var i:int = 0; i < mc.totalFrames; i++)
			{
				mc.gotoAndStop(i);
				frameBounds.push(BoundsUtil.getFrameBounds(mc));
			}
		}
		
		public function get(index:int):Rectangle
		{
			if (index >= 0 && index < frameBounds.length)
			{
				return frameBounds[index];
			}
			return null;
		}
		
		public function get length():int
		{
			return frameBounds.length;
		}
	}
}